<template>
  <a-drawer
    title="异常日志详情"
    placement="right"
    :closable="true"
    :width="1080"
    :visible="visible"
    @close="onClose"
  >
    <a-spin :spinning="spinning">
      <a-descriptions
        bordered
        class="eip-descriptions"
        size="small"
        :column="{ xxl: 1, xl: 3, lg: 3, md: 3, sm: 2, xs: 1 }"
      >
        <a-descriptions-item label="错误时间">
          {{ log.createTime }}
        </a-descriptions-item>
        <a-descriptions-item label="错误信息">
          {{ log.message }}
        </a-descriptions-item>
        <a-descriptions-item label="请求Url">
          {{ log.requestUrl }}
        </a-descriptions-item>
        <a-descriptions-item label="内部信息">
          {{ log.innerException }}
        </a-descriptions-item>
        <a-descriptions-item label="登录名">
          {{ log.createUserCode }}
        </a-descriptions-item>
        <a-descriptions-item label="名称">
          {{ log.createUserName }}
        </a-descriptions-item>
        <a-descriptions-item label="请求方式">
          {{ log.httpMethod }}
        </a-descriptions-item>
        <a-descriptions-item label="请求数据">
          {{ log.requestData }}
        </a-descriptions-item>
        <a-descriptions-item label="IP">
          {{ log.remoteIp }}</a-descriptions-item
        >
        <a-descriptions-item label="地址">
          {{ log.remoteIpAddress }}</a-descriptions-item
        >
        <a-descriptions-item label="浏览器">
          {{ log.navigator }}
        </a-descriptions-item>
        <a-descriptions-item label="堆栈信息">
          {{ log.stackTrace }}
        </a-descriptions-item>
      </a-descriptions>
    </a-spin>
  </a-drawer>
</template>
<script>
import { findById } from "@/services/system/log/exception-detail";
export default {
  name: "detail",
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return { log: {}, spinning: false };
  },
  methods: {
    showDrawer() {
      this.$emit("close");
    },
    onClose() {
      this.$emit("close");
    },
    /**
     * 根据Id查找
     */
    find(id) {
      let _this = this;
      _this.spinning = true;
      findById(id).then(function(result) {
        let form = result.data;
        _this.log.createTime = form.createTime;
        _this.log.createUserCode = form.createUserCode;
        _this.log.createUserName = form.createUserName;
        _this.log.message = form.message;
        _this.log.requestUrl = form.requestUrl;
        _this.log.innerException = form.innerException;
        _this.log.httpMethod = form.httpMethod;
        _this.log.requestData = form.requestData;
        _this.log.remoteIp = form.remoteIp;
        _this.log.remoteIpAddress = form.remoteIpAddress;
        _this.log.navigator = form.navigator;
        _this.log.stackTrace = form.stackTrace;
        _this.spinning = false;
      });
    },
  },
};
</script>
